package com.admin.domain.modle;

import com.alibaba.fastjson.JSON;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * description 演出表 User: WeiDa Date: 2017-4-11 Time: 17:24
 */
public class Play implements Serializable {

	/**
	 * 唯一资源编码
	 */
	private String playId = UUID.randomUUID().toString();

	/**
	 * 接口id
	 */
	private Integer id;

	/**
	 * 资源名称
	 */
	private String name;

	/**
	 * 图片地址
	 */
	private String url;

	/**
	 * 描述 演出详情描述
	 */
	private String content;

	private String code;

	private Integer minPrice;

	private Integer maxPrice;

	/**
	 * -1 :删除 未开始 204001 正在售票 204002 正在演出 204003 已结束 204004
	 */
	private Integer status;

	/**
	 * 演出时间
	 */
	private String playDate;
	private int hour;
	private int minute;

	/**预售开始时间  至 预售结束时间  排除禁售时间  默认进来初始化当天到未来30天的时间段*/
	private String saleDate;

	private Date createTime;
	/**排序*/
	private int orderNum;


	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getPlayId() {
		return playId;
	}

	public void setPlayId(String playId) {
		this.playId = playId;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getMinPrice() {
		return minPrice;
	}

	public void setMinPrice(Integer minPrice) {
		this.minPrice = minPrice;
	}

	public Integer getMaxPrice() {
		return maxPrice;
	}

	public void setMaxPrice(Integer maxPrice) {
		this.maxPrice = maxPrice;
	}

	public String getPlayDate() {
		return playDate;
	}

	public void setPlayDate(String playDate) {
		this.playDate = playDate;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Integer getStatus() {
		return status;
	}

	public String getStatusDesc() {
		if (status != null) {
			switch (status.intValue()) {
			case 204001:
				return "未开始";
			case 204002:
				return "正在售票";
			case 204003:
				return "正在演出";
			case 204004:
				return "已结束";
			case -1:
				return "已删除";
			}
		}
		return "";
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public int getHour() {
		return hour;
	}

	public void setHour(int hour) {
		this.hour = hour;
	}

	public int getMinute() {
		return minute;
	}

	public String getPlayDate2() {
		return hour + ":" + minute;
	}

	public String getPlayDate3() {
		List<String> saleDates = getSaleDates();
		if (!saleDates.isEmpty()) {
			return saleDates.get(0) + " - "
					+ saleDates.get(saleDates.size() - 1);
		}
		return "";
	}

	public void setMinute(int minute) {
		this.minute = minute;
	}

	public String getSaleDate() {
		return saleDate;
	}

	public void setSaleDate(String saleDate) {
		this.saleDate = saleDate;
	}

	public List<String> getSaleDates() {
		if (StringUtils.isEmpty(saleDate)) {
			return Collections.EMPTY_LIST;
		}
		return JSON.parseArray(saleDate, String.class);
	}

	public int getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(int orderNum) {
		this.orderNum = orderNum;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		Play play = (Play) o;

		return id != null ? id.equals(play.id) : play.id == null;

	}

	@Override
	public int hashCode() {
		return id != null ? id.hashCode() : 0;
	}

	@Override
	public String toString() {
		return "Play [playId=" + playId + ", id=" + id + ", name=" + name
				+ ", url=" + url + ", content=" + content + ", code=" + code
				+ ", minPrice=" + minPrice + ", maxPrice=" + maxPrice
				+ ", status=" + status + ", playDate=" + playDate + ", hour="
				+ hour + ", minute=" + minute + ", saleDate=" + saleDate
				+ ", createTime=" + createTime + "]";
	}
}
